package com.jeeplus.cms.config.freemarker.function;

import com.jeeplus.cms.util.CmsUtils;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author WuXilin
 */
@Component
public class GetRecommendList implements TemplateMethodModelEx {

    @Override
    public Object exec(List list) throws TemplateModelException {
        String siteId = String.valueOf(list.get(0));
        String isPreview = String.valueOf(list.get(1));
        String columnId = String.valueOf(list.get(2));
        String contentsId = list.size() < 4 ? "": list.get(3) == null ? "" : String.valueOf(list.get(3));
        return CmsUtils.getRecommendList(siteId, isPreview, columnId, contentsId);
    }
}
